package cn.hx.mallBlog.service.impl;

import cn.hx.mallBlog.dao.CmsTopicDao;
import cn.hx.mallBlog.entity.CmsTopic;
import cn.hx.mallBlog.service.CmsTopicService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 话题表(CmsTopic)表服务实现类
 *
 * @author makejava
 * @since 2022-11-30 15:36:10
 */
@Service("cmsTopicService")
public class CmsTopicServiceImpl implements CmsTopicService {
    @Resource
    private CmsTopicDao cmsTopicDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */


    @Override
    public CmsTopic queryById(Integer id) {
        return cmsTopicDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CmsTopic> queryAllByLimit(int offset, int limit) {
        return this.cmsTopicDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param cmsTopic 实例对象
     * @return 实例对象
     */
    @Override
    public CmsTopic insert(CmsTopic cmsTopic) {
        this.cmsTopicDao.insert(cmsTopic);
        return cmsTopic;
    }

    /**
     * 修改数据
     *
     * @param cmsTopic 实例对象
     * @return 实例对象
     */
    @Override
    public CmsTopic update(CmsTopic cmsTopic) {
        this.cmsTopicDao.update(cmsTopic);
        return this.queryById(cmsTopic.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.cmsTopicDao.deleteById(id) > 0;
    }

    @Override
    public List<CmsTopic> queryAll(CmsTopic cmsTopic) {
        return cmsTopicDao.queryAll(cmsTopic);
    }

    @Override
    public List<CmsTopic> queryByCategoryIdCmsTopic(Integer id) {
        return cmsTopicDao.queryByCategoryIdCmsTopic(id);
    }

    @Override
    public List<CmsTopic> timeList() {
        return cmsTopicDao.timeList();
    }
    @Override
    public CmsTopic queryByCreateTime(String createTime) {
        return cmsTopicDao.queryByCreateTime(createTime);
    }

    @Override
    public CmsTopic queryByOldTime(String formatTime) {
        return cmsTopicDao.queryByOldTime(formatTime);
    }

    @Override
    public List<CmsTopic> findAllByLimit(int offset, int limit) {
        return cmsTopicDao.findAllByLimit(offset, limit);
    }
}